import { BasicDrawer, useDrawerInner } from "@/components/Drawer";
import { BasicForm, FormSchema, useForm } from "@/components/Form";
// import { Select } from "antd";
import { useTranslation } from "react-i18next";
// const { Option } = Select;
let addTableData: Function;
const index = (props: { register: Fn }) => {
	const { t } = useTranslation();
	const schemas: FormSchema[] = [
		{
			label: t("kevin_ui.from_date"),
			field: "tu_ngay",
			component: "DatePicker",
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.to"),
			field: "den",
			component: "DatePicker",
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.type"),
			field: "loai",
			component: "Select",
			componentProps: {
				options: [
					{ label: "Routine Checkup", value: "常规检查" },
					{ label: "Surgical Record", value: "手术记录" },
					{ label: "Follow-up Record", value: "复查记录" }
				]
			},
			colProps: {
				span: 24
			}
		},
		{
			label: t("felix_ui.dept_name"),
			field: "khoa_phong",
			component: "Select",
			componentProps: {
				options: [
					{ label: "Internal Medicine", value: "内科" },
					{ label: "Surgery", value: "外科" },
					{ label: "Pediatrics", value: "儿科" }
				]
			},
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.pat_subject"),
			field: "doi_tuong",
			component: "Select",
			componentProps: {
				options: [
					{ label: "Outpatient", value: "门诊患者" },
					{ label: "Inpatient", value: "住院患者" },
					{ label: "Pediatric Patient", value: "儿童患者" }
				]
			},
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.content"),
			field: "noi_dung",
			component: "Input",
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.billed_case"),
			field: "ca_chi_dinh",
			component: "Input",
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.collected_ase"),
			field: "ca_thu_tien",
			component: "Input",
			colProps: {
				span: 24
			}
		},
		{
			label: t("kevin_ui.amount_collected"),
			field: "so_tien_da_thu",
			component: "Input",
			colProps: {
				span: 24
			}
		}
	];
	const [registerDrawer, { closeDrawer }] = useDrawerInner(props.register, data => {
		console.log("打开Drawer", data);
		addTableData = data.addTableData;
	});
	const [register, { getFieldsValue }] = useForm({
		schemas,
		labelWidth: 180
	});
	const handleSubmit = async () => {
		console.log(1023);
		const res = await getFieldsValue();
		addTableData(res);
		closeDrawer();
	};
	return (
		<BasicDrawer showFooter={true} size="large" {...props} register={registerDrawer} ok={handleSubmit}>
			<BasicForm register={register}></BasicForm>
		</BasicDrawer>
	);
};
export default index;
